<template>
  <div class="goods">
    <ul>
      <li v-for="item in goodsList" :key="item.id" @click="gotoDetail(item)" >
        <img :src="item.list_pic_url" alt="" />
        <p>{{ item.name }}</p>
        <span>{{ item.retail_price | formatMoey }}</span>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: "GoodsList",
  props: ["goodsList"],
  data() {
    return {};
  },
  methods: {
    gotoDetail(item) {
      // console.log(item);
      this.$router.push({ path: "/productDetail", query: { id: item.id } });
    },
  },
};
</script>

<style lang='less' scoped>
.goods {
  ul {
    display: flex;
    flex-wrap: wrap;
    li {
      width: 50%;
      padding: 3px;
      box-sizing: border-box;
      img {
        width: 100%;
        display: block;
      }
      p {
        font-size: 8px;
        text-align: center;
        margin-top: 5px;
        white-space: nowrap;
        /* 设置文本不换行 */
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }
  }
}
span {
  color: #8b0000;
  font-size: 8px;
  text-align: center;
}
</style>